import CesiumApp from '../CesiumApp';

export function customMouseConfig(viewer, iCesium) {
	const scene = viewer.scene;
	const handler = viewer.cesiumWidget.screenSpaceEventHandler;
	const controller = scene.screenSpaceCameraController;

	handler.removeInputAction(iCesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);
	controller.rotateEventTypes = iCesium.CameraEventType.LEFT_DRAG;
	controller.zoomEventTypes = iCesium.CameraEventType.WHEEL;
	controller.tiltEventTypes = [
		iCesium.CameraEventType.MIDDLE_DRAG,
		iCesium.CameraEventType.RIGHT_DRAG
	];

	// scene.debugShowFramesPerSecond = true

	let doubleClickFlag = false;
	handler.setInputAction((e) => {
		if (doubleClickFlag) {
			CesiumApp.camera.homeView();
		} else {
			doubleClickFlag = true;
			setTimeout(() => {
				doubleClickFlag = false;
			}, 250);
		}
	}, iCesium.ScreenSpaceEventType.MIDDLE_CLICK);
}
